
#include "ConnectionTable.h"

ConnectionTable::ConnectionTable(){

}

void ConnectionTable::handleOutput(Outbox &outbox, double procTime){
	for (std::set<int>::iterator it = outbox.clients.begin(); it != outbox.clients.end(); it++){
		int connectionId = *it;
		boost::unordered_map<int, ResultListener* >::iterator itListener = connectionToListenerMap.find(connectionId);
		if (itListener != connectionToListenerMap.end()){
			ResultListener* listener = itListener->second;
	//		listener->handleResult(outbox->getPkts(), (double)0);
		}
	}
}

void ConnectionTable::registerConnection(int idConnection, ResultListener* listener){
	if (connectionToListenerMap.find(idConnection) == connectionToListenerMap.end()){
		connectionToListenerMap.insert(make_pair(idConnection, listener));
	}
}


void ConnectionTable::removeConnection(int idConnection){
	if (connectionToListenerMap.find(idConnection) != connectionToListenerMap.end()){
		connectionToListenerMap.erase(idConnection);
	}
}
